//
//  ErrorFaseController.m
//  NtoccDriverNew
//
//  Created by 张天兴 on 2025/7/4.
//  Copyright © 2025 GCY. All rights reserved.
//

#import "ErrorFaseController.h"
#import "AutonymNameController.h"
#import "DriverAuthenticationController.h"

@interface ErrorFaseController ()
@property (nonatomic, strong) NSString *phone;
@end

@implementation ErrorFaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"人脸识别"];
    self.view.backgroundColor = BackgroundColor;
    self.comittButton.layer.masksToBounds = YES;
    self.comittButton.layer.cornerRadius = 10;
    [self networkingType];
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)statFaceButtonAction:(UIButton *)sender {
    
}
- (void)typeAction{
    if ([self.typeStr isEqualToString:@"FAIL"] && [self.isOldStr isEqualToString:@"0"]) {
        self.strtTypeLabel.text = @"人脸识别失败";
        self.strtTypeLabel.backgroundColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        self.strtTypeLabel.layer.masksToBounds = YES;
        self.strtTypeLabel.layer.cornerRadius = 10;
        self.typeImagView.image = [UIImage imageNamed:@"commitError"];
        self.infoLabel.text = @"身份信息有误,请重新尝试人脸识别";
        self.infoLabel.textColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        self.comittButton.backgroundColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        [self.comittButton setTitle:@"重新开始人脸识别" forState:(UIControlStateNormal)];
        [self.comittButton addTarget:self action:@selector(comittRuturnAction) forControlEvents:(UIControlEventTouchUpInside)];
    }else if ([self.typeStr isEqualToString:@"FAIL"]&& [self.isOldStr isEqualToString:@"1"]){
        self.strtTypeLabel.text = @"人脸识别失败";
        self.strtTypeLabel.backgroundColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        self.strtTypeLabel.layer.masksToBounds = YES;
        self.strtTypeLabel.layer.cornerRadius = 10;
        self.typeImagView.image = [UIImage imageNamed:@"commitError"];
        self.infoLabel.text = @"身份信息有误,请联系人工客服";
        self.infoLabel.textColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        self.comittButton.backgroundColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        [self.comittButton setTitle:@"400002888" forState:(UIControlStateNormal)];
        [self.comittButton addTarget:self action:@selector(comittPhoneAction) forControlEvents:(UIControlEventTouchUpInside)];

    }else if([self.typeStr isEqualToString:@"SUCCESS"]){
        self.strtTypeLabel.text = @"人脸识别成功";
        self.strtTypeLabel.backgroundColor = [UIColor colorWithRed:0/255.0 green:169/255.0 blue:157/255.0 alpha:1];
        self.strtTypeLabel.layer.masksToBounds = YES;
        self.strtTypeLabel.layer.cornerRadius = 10;
        self.typeImagView.image = [UIImage imageNamed:@"commitSuss"];
        self.infoLabel.text = @"人脸识别成功,下一步开始司机认证";
        self.infoLabel.textColor = [UIColor colorWithRed:0/255.0 green:169/255.0 blue:157/255.0 alpha:1];
        self.comittButton.backgroundColor = [UIColor colorWithRed:0/255.0 green:169/255.0 blue:157/255.0 alpha:1];
        [self.comittButton setTitle:@"下一步" forState:(UIControlStateNormal)];
        [self.comittButton addTarget:self action:@selector(comittRuturnHomeAction) forControlEvents:(UIControlEventTouchUpInside)];

    }else{
        self.strtTypeLabel.text = @"人脸识别失败";
        self.strtTypeLabel.backgroundColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        self.strtTypeLabel.layer.masksToBounds = YES;
        self.strtTypeLabel.layer.cornerRadius = 10;
        self.typeImagView.image = [UIImage imageNamed:@"commitError"];
        self.infoLabel.text = @"身份信息有误,请重新尝试人脸识别";
        self.infoLabel.textColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        self.comittButton.backgroundColor = [UIColor colorWithRed:237/255.0 green:107/255.0 blue:134/255.0 alpha:1];
        [self.comittButton setTitle:@"重新开始人脸识别" forState:(UIControlStateNormal)];
        [self.comittButton addTarget:self action:@selector(comittRuturnAction) forControlEvents:(UIControlEventTouchUpInside)];
    }
}
- (void)comittRuturnAction{
    [self.navigationController popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)networkingType{
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setValue:self.dataDic[@"flowId"] forKey:@"flowId"];
    [parmas setValue:self.IDcodeTime forKey:@"idCardDueDate"];
    [parmas setValue:self.address forKey:@"address"];

    [HTTPManager postNetworkRequest:CJStringWithFormat(@"%@%@", [NSString stringWithFormat:@"%@/ntocc-basic-api",[ReAddressDynamic shared].baseUrl], AuthenticationQueryAuthStatus) withParameter:parmas withVC:self netName:@"实名认证状态查询" success:^(id response, NSString *msg) {
        [XSInfoView showInfo:msg onView:self.view];
        self.typeStr = response[@"status"];
        self.phone = response[@"y8Phone"];
        [self typeAction];
        } failure:^(NSInteger code, NSString *msg) {
            
        }];
}
- (void)comittRuturnHomeAction{
//    [self.navigationController popToRootViewControllerAnimated:YES];
    DriverAuthenticationController *diVC = [[DriverAuthenticationController alloc] init];
    diVC.sussType = @"0";
    [self.navigationController pushViewController:diVC animated:YES];
}
-(void)comittPhoneAction{
    CALL_PHONE(self.phone);
}
@end
